package com.cjg.Class;

public class demo01 {
    public static void main(String[] args) throws ClassNotFoundException {
        //通过反射获取Class类的对象
        Class c1 = Class.forName("com.cjg.Class.Student");
        System.out.println(c1);//class com.cjg.Class.Student


        //一个类在内存中 只有一个Class对象
        //一个类被加载后,类的结构会被封装在Class类中
        Class c2 = Class.forName("com.cjg.Class.Student");
        Class c3 = Class.forName("com.cjg.Class.Student");
        System.out.println(c2.hashCode()==c3.hashCode());//true


    }



}
//创建一个实体类
class Student{
    private String name;
    private int age;
    private int num;

    public Student() {
    }

    public Student(String name, int age, int num) {
        this.name = name;
        this.age = age;
        this.num = num;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", num=" + num +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }
}